<?php
require_once '../core/fcCommon.php';
require_once '../core/fcORM.php';

$obj = new Entity("some_table");
$obj->put('my_key', 'a');
//$obj->put('my_val', 'กวนตีน');
//$obj->put('update_time', date("Y-m-d H:i:s"));

$conn = new Connection();

//1. create
//$conn->persist($obj)."<br/>";
//2. retrieve
//$res = $conn->find($obj);
//foreach($res as $re){
//    $obj = cast($re, Entity);
//    echo $obj->get('update_time')."<br/>";
//}
//3. update
//$obj = new Entity("some_table");
//$obj->put("id", 8);
//$res = $conn->find($obj);
//foreach($res as $re){
//    $obj = cast($re, Entity);
//    echo $obj->get('update_time')."<br/>";
//    
//    $condition = new Map();
//    $condition->put("id", 8);
//    
//    $obj->put('update_time', date("Y-m-d H:i:s", time() - 3600));
//    
//    $conn->merge($obj, $condition);
//}
//4. delete
$obj = new Entity("some_table");
$obj->put("id", 10);
$conn->remove($obj);

//echo date_default_timezone_get();
?>
